﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity.InterceptionExtension;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration;
using System.Collections.Specialized;

namespace PolicyInjectionExtension.UnitTest
{

    [ConfigurationElementType(typeof(CustomMatchingRuleData))]
    public class OrderValidationMatchingRule:IMatchingRule
    {
        public OrderValidationMatchingRule()
        {
            MatchName = "";
        }

        public OrderValidationMatchingRule(NameValueCollection collection)
            :this()
        {
            if (collection["MatchName"] != null)
                MatchName = collection["MatchName"];
        }

        public string MatchName
        {
            get;
            set;
        }

        #region IMatchingRule Members

        public bool Matches(System.Reflection.MethodBase member)
        {
            return (member.Name == MatchName);            
        }

        #endregion
    }

    [ConfigurationElementType(typeof(CustomMatchingRuleData))]
    public class OrderValidationMatchingRule0 : IMatchingRule
    {
        public OrderValidationMatchingRule0()
        {
            MatchName = "";
        }

        public OrderValidationMatchingRule0(NameValueCollection collection)
            : this()
        {
            if (collection["MatchName"] != null)
                MatchName = collection["MatchName"];
        }

        public string MatchName
        {
            get;
            set;
        }

        #region IMatchingRule Members

        public bool Matches(System.Reflection.MethodBase member)
        {
            return (member.Name == MatchName);
        }

        #endregion
    }
}
